(function () {
    'use strict';

    angular
        .module('logcenterApp')
        .controller('platformDashController', platformDashController);
    platformDashController.$inject = ['$scope', '$sce', 'ACTIVE', 'isMulti', 'kibanaPartition', 'platformDashService', 'transerCountService', '$interval'];

    function platformDashController($scope, $sce, active, isMulti, kibanaPartition, platformDashService, transerCountService, $interval) {
        $scope.currentTime = new Date();
        $scope.startTime = getToday00Clock().Format("yyyy-MM-ddThh:mm:ss.S");
        $scope.endTime = getToday11Clock().Format("yyyy-MM-ddThh:mm:ss.S");
        $scope.timeType = "1d";
        $scope.interval = 1800000;
        $scope.isMulti = isMulti;
        $interval.cancel(timer);
        var callFrameServiceEchart;
        var partitionArr = [];
        var partitionSrc = [];
        var arr = [];
        var yCount = [];
        var yCount1 = [];
        var title = [];
        var sh;
        var nj;
        var zj;
        var wh;
        var shTotal = 0;
        var njTotal = 0;
        var zjTotal = 0;
        var whTotal = 0;
        var shPostionLat;
        var njPostionLat;
        var zjPostionLat;
        var whPostionLat;
        var shPostionLon;
        var njPostionLon;
        var zjPostionLon;
        var whPostionLon;
        var timer;
        queryLoginTotal();
        queryCallServiceTotal();
        queryFrameTotal();
        queryAsyncRouteSendTotal();
        queryAsyncRouteReceiveTotal();
        queryBatchTotal();
        callServiceLine();
        timer = $interval(function () {
            queryLoginTotal();
            queryCallServiceTotal();
            queryFrameTotal();
            queryAsyncRouteSendTotal();
            queryAsyncRouteReceiveTotal();
            queryBatchTotal();
            callServiceLine();
        }, 60000);
        if (isMulti == 'true') {
            mapService();
            timer = $interval(function () {
                mapService();
            }, 60000);
        } else if (isMulti == 'false') {
            queryCallFrameServiceTop10()
            timer = $interval(function () {
                queryCallFrameServiceTop10()
            }, 60000);
        }

        asyncRouteLine();

        function queryLoginTotal() {
            platformDashService.queryLoginTotal($scope.startTime, $scope.endTime, active).then(
                function (resp) {
                    $scope.loginTotal = resp.total;

                }, function (error) {
                    console.log(error);
                    notify('error', '失败', error.message);
                });
        }

        function queryCallServiceTotal() {
            platformDashService.queryCallServiceTotal($scope.startTime, $scope.endTime, active).then(
                function (resp) {
                    $scope.callServiceTotal = resp.total;

                }, function (error) {
                    console.log(error);
                    notify('error', '失败', error.message);
                });
        }

        function queryFrameTotal() {
            platformDashService.queryFrameTotal($scope.startTime, $scope.endTime, active).then(
                function (resp) {
                    $scope.frameTotal = resp.total;
                }, function (error) {
                    console.log(error);
                    notify('error', '失败', error.message);
                });
        }

        function queryAsyncRouteSendTotal() {
            platformDashService.queryAsyncRouteSendTotal($scope.startTime, $scope.endTime, active).then(
                function (resp) {
                    $scope.asyncRouteSendTotal = resp.total;
                }, function (error) {
                    console.log(error);
                    notify('error', '失败', error.message);
                });
        }

        function queryAsyncRouteReceiveTotal() {
            platformDashService.queryAsyncRouteReceiveTotal($scope.startTime, $scope.endTime, active).then(
                function (resp) {
                    $scope.asyncRouteReceiveTotal = resp.total;
                }, function (error) {
                    console.log(error);
                    notify('error', '失败', error.message);
                });
        }

        function callServiceLine() {
            platformDashService.callServiceLine($scope.startTime, $scope.endTime, $scope.interval, active).then(
                function (resp) {
                    callServiceLineAnalysis(resp);
                }, function (error) {
                    console.log(error);
                    notify('error', '失败', error.message);
                });
        }


        function callServiceLineAnalysis(data) {
            var xTime = [];
            var timeArr = [];
            var timeAndCountArr = [];
            var timekey1 = [];
            var timeValue = [];
            yCount = [];
            title = [];
            arr = [];
            if (data.length != 0) {
                angular.forEach(data, function (item) {
                    timeAndCountArr.push(item.hashMap);
                    title.push(item.service);
                });
                angular.forEach(timeAndCountArr, function (item) {
                    for (var key in item) {
                        // key = timestampToTime(key);
                        if (timeArr.indexOf(key) == -1) {
                            timeArr.push(key);
                        }
                    }
                });
                timeArr = timeArr.sort();
                angular.forEach(timeArr, function (item) {
                    xTime.push(timestampToTime(item));
                })

                angular.forEach(timeAndCountArr, function (item) {
                    timekey1 = [];
                    timeValue = [];
                    for (var timeKey in item) {
                        timekey1.push(timestampToTime(timeKey));
                        timeValue.push(item[timeKey]);
                    }
                    angular.forEach(xTime, function (time) {

                        if (timekey1.includes(time)) {
                            for (var i = 0; i < timekey1.length; i++) {
                                if (timekey1[i] == time) {
                                    yCount.push(timeValue[i]);
                                }
                            }
                        } else {
                            yCount.push("0");
                        }

                    })

                })

                var callServiceLineOption = {

                    title: {
                        text: kibanaPartition + "服务调用走势",
                        textStyle: {
                            color: "#6d6d6d",
                            fontSize: 15,
                            fontWeight: "bold",
                            top: "2%"
                        }
                    },
                    legend: {
                        orient: 'horizontal',
                        top: '5%',
                        right: '0%',
                        bottom: '3%',
                        data: title
                    },
                    tooltip: {
                        trigger: 'axis',
                        position: function (pos, params, dom, rect, size) {
                            // 鼠标在左侧时 tooltip 显示到右侧，鼠标在右侧时 tooltip 显示到左侧。
                            var obj = {top: 60};
                            obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 5;
                            return obj;
                        },
                        axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                            type: 'line'        // 默认为直线，可选为：'line' | 'shadow'
                        }
                    },


                    toolbox: {
                        show: true,
                        orient: 'vertical'
                    },
                    grid: {
                        top: '20%',
                        left: '4%',
                        right: '4%',
                        bottom: '8%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: xTime,
                            nameTextStyle: {
                                padding: 5
                            },
                            name: 'Time',
                            nameLocation: "center",
                            nameGap: 65,
                            axisTick: {
                                alignWithLabel: true
                            },
                            axisLabel: {
                                // rotate: 60
                            }
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value',
                            name: "Count",
                            nameRotate: "90",
                            nameLocation: "center",
                            nameGap: 35,
                            splitLine: { //网格线
                                show: true
                            },
                            textStyle: {
                                fontSize: 14,
                                fontWeight: "bold",
                            }
                        }
                    ],
                    series: callServiceLineSeries(xTime.length, title.length)
                };
                if (isMulti === 'false') {
                    var callServiceLineEcharts = echarts.init(angular.element('#callServiceLineEchartsf')[0]);
                } else {
                    var callServiceLineEcharts = echarts.init(angular.element('#callServiceLineEcharts')[0]);
                }

                callServiceLineEcharts.setOption(callServiceLineOption, true);
            } else {
                var callServiceLineOption = {
                    title: {
                        text: kibanaPartition + "后台上线排行",
                        textStyle: {
                            color: "#6d6d6d",
                            fontSize: 15,
                            fontWeight: "bold",
                            top: "2%"
                        }
                    }

                };

                if (isMulti === 'false') {
                    var callServiceLineEcharts = echarts.init(angular.element('#callServiceLineEchartsf')[0]);
                } else {
                    var callServiceLineEcharts = echarts.init(angular.element('#callServiceLineEcharts')[0]);
                }
                callServiceLineEcharts.setOption(callServiceLineOption, true);
            }
            ;

        }

        function callServiceLineSeries(xLength, partitionLength) {
            var lgend_data = [];
            for (var i = 0; i < partitionLength; i++) {
                var item = {
                    name: title[i],
                    type: 'line',
                    data: yCount.splice(0, xLength)
                }

                lgend_data.push(item);
            }
            ;
            return lgend_data;
        }


        function queryCallFrameServiceTop10() {
            transerCountService.callFrameServiceTop10(kibanaPartition, $scope.startTime, $scope.endTime, "", active).then(
                function (resp) {
                    callFrameServiceAnalysis(resp);
                    console.log(resp)
                }, function (error) {
                    console.log(error);
                    notify('error', '失败', error.message);
                });
        }

        function callFrameServiceAnalysis(data) {

            var xTime = [];
            var yCount = [];
            if (data.length != 0) {
                angular.forEach(data, function (item) {
                        xTime.push(item.service);
                        yCount.push(item.count);
                    }
                );
                var callFrameServiceOption = {

                    color: ['#663DB8'],
                    title: {
                        text: kibanaPartition + "画面调用Top10",
                        textStyle: {
                            color: "#6d6d6d",
                            fontSize: 15,
                            fontWeight: "bold",
                            top: "2%"
                        }
                    },
                    legend: {
                        left: "right",
                        data: ['画面访问次数']
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                        },
                        formatter: function (params) {
                            var res = "";
                            angular.forEach(params, function (item) {
                                res += "<span >画面访问次数:" + "&emsp;" + item.value + '</span>' + '<br>' + '<hr>'
                                    + "<span>画面代码:" + "&emsp;" + item.name + "</span>"
                            });
                            return res;
                        }
                    },
                    grid: {
                        left: '4%',
                        right: '4%',
                        bottom: '8%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: xTime,
                            name: '画面代码',
                            nameLocation: "center",
                            nameGap: 130,
                            axisTick: {
                                alignWithLabel: true
                            },
                            axisLabel: {
                                rotate: 45
                            }
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value',
                            //name:"",
                            nameRotate: "90",
                            nameLocation: "center",
                            nameGap: 40,
                            splitLine: { //网格线
                                show: true
                            },
                            textStyle: {
                                fontSize: 14,
                                fontWeight: "bold",
                            }
                        }
                    ],
                    series: [
                        {
                            name: '画面访问次数',
                            type: 'bar',
                            barWidth: '60%',
                            barMinHeight: 1,
                            data: yCount
                        }
                    ]

                }
                if (isMulti == 'false') {
                    callFrameServiceEchart = echarts.init(angular.element('#callFrameServiceEchart')[0]);
                }
                callFrameServiceEchart.setOption(callFrameServiceOption, true);
            } else {
                var callFrameServiceOption = {
                    title: {
                        text: kibanaPartition + "画面调用Top10",
                        textStyle: {
                            color: "#6d6d6d",
                            fontSize: 15,
                            fontWeight: "bold",
                            top: "2%"
                        }
                    },
                    noDataLoadingOption: {
                        text: '暂无数据',
                        effect: 'bubble',
                        effectOption: {
                            effect: {
                                n: 0
                            }
                        }
                    }
                };
                if (isMulti == 'false') {
                    callFrameServiceEchart = echarts.init(angular.element('#callFrameServiceEchart')[0]);
                }
                callFrameServiceEchart.setOption(callFrameServiceOption, true);
            }
            ;
        }


        function queryBatchTotal() {
            platformDashService.queryBatchTotal($scope.startTime, $scope.endTime, active).then(
                function (resp) {
                    $scope.batchTotal = resp.total;
                }, function (error) {
                    console.log(error);
                    notify('error', '失败', error.message);
                });
        }


        function asyncRouteLine() {
            platformDashService.asyncRouteLine($scope.startTime, $scope.endTime, $scope.interval, active).then(
                function (resp) {
                    asyncRouteLineAnalysis(resp)
                }, function (error) {
                    console.log(error);
                    notify('error', '失败', error.message);
                });
        }


        function mapService() {

            platformDashService.mapService($scope.startTime, $scope.endTime, active).then(
                function (resp) {
                    console.log(resp)
                    var geoCoordMap;
                    var SHData;
                    angular.forEach(resp, function (item) {
                        if (item.position.geohash === 'wtw6sn5b80ku') {
                            sh = item
                            shTotal = item.total;
                            shPostionLat = sh.position.lat.toFixed(2);
                            shPostionLon = sh.position.lon.toFixed(2);
                        } else if (item.position.geohash === 'wtsm7q8mqrfb') {
                            nj = item;
                            njTotal = item.total;
                            njPostionLat = nj.position.lat.toFixed(2);
                            njPostionLon = nj.position.lon.toFixed(2);
                        } else if (item.position.geohash === 'w7y3pdqy3yf0') {
                            zj = item;
                            zjTotal = item.total;
                            zjPostionLat = zj.position.lat.toFixed(2);
                            zjPostionLon = zj.position.lon.toFixed(2);
                        } else if (item.position.geohash === 'wt3qhm7cq39k') {
                            wh = item;
                            whTotal = item.total;
                            whPostionLat = wh.position.lat.toFixed(2);
                            whPostionLon = wh.position.lon.toFixed(2);
                        }
                    })
                    geoCoordMap = {
                        "上海": [shPostionLon, shPostionLat],  //wtw6sn5b80ku
                        "湛江": [zjPostionLon, zjPostionLat],//w7y3pdqy3yf0
                        "武汉": [whPostionLon, whPostionLat],//wt3qhm7cq39k
                        "南京": [njPostionLon, njPostionLat],//wt3qhm7cq39k
                    };

                    SHData = [
                        [{name: '上海'}, {name: '上海', value: shTotal}],
                        [{name: '上海'}, {name: '湛江', value: zjTotal}],
                        [{name: '上海'}, {name: '武汉', value: whTotal}],
                        [{name: '上海'}, {name: '南京', value: njTotal}],
                    ];

                    var convertData = function (data) {
                        var res = [];
                        for (var i = 0; i < data.length; i++) {
                            var dataItem = data[i];
                            var fromCoord = geoCoordMap[dataItem[1].name];
                            var toCoord = geoCoordMap[dataItem[0].name];
                            if (fromCoord && toCoord) {
                                res.push({
                                    fromName: dataItem[1].name,
                                    toName: dataItem[0].name,
                                    coords: [fromCoord, toCoord]
                                });
                            }
                        }
                        return res;
                    };
                    //var color = ['#a6c84c', '#ffa022', '#46bee9'];
                    var series = [];
                    series.push({
                            type: 'lines',

                            zlevel: 1,
                            effect: {
                                show: true,
                                period: 2,
                                trailLength: 0.9,
                                color: 'yellow',
                                symbolSize: 1   //尾部大小
                            },
                            lineStyle: {
                                normal: {
                                    //color: 'yellow',
                                    width: 0,
                                    curveness: 0.2
                                }
                            },
                            data: convertData(SHData)
                        },

                        {
                            type: 'lines',
                            zlevel: 2,

                            symbol: ['none', 'arrow'],
                            symbolSize: 10,//箭头大小
                            tooltip: {
                                trigger: 'item',
                                formatter: '{b}'

                            },
                            effect: {
                                show: true,
                                period: 6,
                                trailLength: 0,
                                symbol: 'pin',
                                symbolSize: 1//水滴头大小
                            },
                            lineStyle: {
                                normal: {
                                    color: '#00ba29',
                                    width: 4,
                                    opacity: 0.3,
                                    curveness: 0.2
                                }
                            },
                            data: convertData(SHData)
                        },

                        {

                            type: "effectScatter",       //特效散点图
                            silent: false,               //图形是否不响应和触发鼠标事件，默认为 false，即响应和触发鼠标事件。
                            legendHoverLink: true,       //是否启用图例 hover 时的联动高亮。
                            hoverAnimation: true,        //是否开启鼠标 hover 的提示动画效果。
                            effectType: "ripple",        //特效类型，目前只支持涟漪特效'ripple'。
                            showEffectOn: "render",      //配置何时显示特效。可选：'render' 绘制完成后显示特效。'emphasis' 高亮（hover）的时候显示特效。
                            rippleEffect: {              //涟漪特效相关配置。
                                period: 4,               //动画的时间。
                                scale: 4,               //动画中波纹的最大缩放比例。
                                brushType: 'stroke',      //波纹的绘制方式，可选 'stroke' 和 'fill'。
                            },

                            coordinateSystem: 'geo',
                            data: SHData.map(function (dataItem) {
                                return {
                                    name: dataItem[1].name,
                                    value: geoCoordMap[dataItem[1].name].concat([dataItem[1].value])
                                };
                            }),

                            symbolSize: 16,
                            label: {
                                normal: {
                                    show: true,
                                    position: 'top',
                                    formatter: '{b}'
                                },
                                emphasis: {
                                    show: false
                                }
                            },
                            itemStyle: {
                                emphasis: {
                                    borderColor: '#fff',
                                    borderWidth: 1
                                }
                            }
                        });


                    var option = {
                        backgroundColor: '#404a59',
                        title: {
                            text: '宝钢多基地分布图',
                            left: 'center',
                            textStyle: {
                                color: '#f1f1f1'
                            }
                        },
                        tooltip: {
                            trigger: 'item',
                            position: 'top',
                            formatter: function (params) {
                                console.log(typeof (params.data.value))

                                var res = "Address" + ' : ' + params.data.name + "<hr/>";
                                // res = "<span >Count:   "  +params.data.value[2] + '</span>';
                                res += ' Count: ' + params.data.value[2];
                                return res;
                            }

                        },
                        dataRange: {
                            min: 0,
                            max: sh.total,
                            calculable: true,
                            color: ['#ff3333', 'orange', 'yellow', 'lime', 'aqua'],
                            textStyle: {
                                color: '#fff'
                            }
                        },

                        geo: {
                            map: 'china',
                            zoom: 1.4,
                            label: {
                                emphasis: {
                                    show: false
                                }
                            },
                            roam: true,
                            itemStyle: {
                                normal: {
                                    areaColor: '#323c48',
                                    borderColor: '#404a59'
                                },
                                emphasis: {
                                    areaColor: '#2a333d'
                                }
                            }
                        },
                        series: series
                    };
                    if (isMulti === 'true') {
                        var myChart = echarts.init(document.getElementById('mapEchart'));
                    }
                    myChart.setOption(option);
                }, function (error) {
                    console.log(error);
                    notify('error', '失败', error.message);
                });


        }


        function asyncRouteLineAnalysis(data) {
            var key1 = [];
            var value = [];
            var key2 = [];
            var value1 = [];
            var dateArr = [];
            var hashMap2 = [];
            var hashMap1 = [];
            var date = data.time.sort();
            partitionArr = [];
            if (data.length != 0) {
                partitionArr = data.partition;
                angular.forEach(date, function (item) {
                    dateArr.push(timestampToTime(item));
                });


                angular.forEach(partitionArr, function (pa) {
                    hashMap1 = [];
                    //获取 日期与数量map
                    angular.forEach(data.SRC, function (hm) {
                        if (pa == hm.service) {
                            if (partitionSrc.indexOf(hm.service) == -1) {
                                partitionSrc.push(hm.service);
                            }
                            hashMap1.push(hm.hashMap);
                        }
                    });

                    key1 = [];
                    value = [];
                    //遍历map
                    angular.forEach(hashMap1, function (hamap) {

                        for (var key in hamap) {
                            key1.push(timestampToTime(key));
                            value.push(hamap[key]);
                        }
                    });
                    //所有时间与某个分区取交集，value为空设为0，反之value
                    angular.forEach(dateArr, function (date) {
                        if (key1.includes(date)) {
                            for (var i = 0; i < key1.length; i++) {
                                if (key1[i] == date) {
                                    yCount.push(value[i]);
                                }
                            }
                        } else {
                            yCount.push("0");
                        }
                    });

                    hashMap2 = [];
                    angular.forEach(data.SRCXCOMDEST, function (sxd) {
                        if (pa == sxd.service) {
                            hashMap2.push(sxd.hashMap);
                        }
                    });
                    key2 = [];
                    value1 = [];
                    angular.forEach(hashMap2, function (hamap) {
                        for (var key in hamap) {
                            key2.push(timestampToTime(key));
                            value1.push(hamap[key]);
                        }
                    })
                    angular.forEach(dateArr, function (date) {
                        if (key2.includes(date)) {
                            for (var i = 0; i < key2.length; i++) {
                                if (key2[i] == date) {
                                    yCount1.push(value1[i]);
                                }
                            }
                        } else {
                            yCount1.push("0");
                        }
                    });

                });
                var option = {
                    visualMap: [{
                        show: false,
                        type: 'continuous',
                        seriesIndex: 0,
                        min: 0,
                        max: 400
                    }, {
                        show: false,
                        type: 'continuous',
                        seriesIndex: 1,
                        dimension: 0

                    }],
                    legend: {
                        orient: 'horizontal',
                        top: '5%',
                        right: '0%',
                        data: partitionArr
                    },
                    title: [{
                        text: kibanaPartition + "异步路由调用总体走势",
                        textStyle: {
                            color: "#6d6d6d",
                            fontSize: 15,
                            fontWeight: "bold",
                            top: "2%"
                        }
                    }],
                    tooltip: {
                        trigger: 'axis',
                        position: function (point, params, dom) {
                            return [point[-1], '10%'];
                        }

                    },
                    xAxis: [{
                        data: dateArr
                    }, {
                        data: dateArr,
                        gridIndex: 1
                    }],
                    yAxis: [{
                        type: 'value',
                        name: 'SRC: SRC发送；DEST接收',
                        nameRotate: "90",
                        nameGap: 30,
                        nameLocation: "center",
                        splitLine: {show: true}
                    }, {
                        name: 'SRC->XCOM->DEST: SRC发送；DEST接收',
                        nameRotate: "90",
                        nameLocation: "center",
                        nameTextStyle: {
                            fontSize: 12,
                        },
                        nameGap: 30,
                        splitLine: {show: true},
                        gridIndex: 1
                    }],
                    grid: [{
                        top: '20%',
                        bottom: '50%'
                    }, {
                        top: '60%'
                    }],
                    series: syncRouteLineSeries(dateArr.length, partitionArr.length, partitionSrc.length)
                };
                if (isMulti === 'false') {
                    var asyncRouteLineEcharts = echarts.init(angular.element('#asyncRouteLineEchartsf')[0]);
                } else {
                    var asyncRouteLineEcharts = echarts.init(angular.element('#asyncRouteLineEcharts')[0]);
                }
                asyncRouteLineEcharts.setOption(option, true);

            } else {
                var option = {
                    title: {
                        text: kibanaPartition + "异步路由调用总体走势",
                        textStyle: {
                            color: "#6d6d6d",
                            fontSize: 15,
                            fontWeight: "bold",
                            top: "2%"
                        }
                    }

                };

                if (isMulti === 'false') {
                    var asyncRouteLineEcharts = echarts.init(angular.element('#asyncRouteLineEchartsf')[0]);
                } else {
                    var asyncRouteLineEcharts = echarts.init(angular.element('#asyncRouteLineEcharts')[0]);
                }
                asyncRouteLineEcharts.setOption(option, true);
            }

        }

        function syncRouteLineSeries(dateLength, partitionLength, srcLength) {
            var lgend_data = [];
            for (var i = 0; i < srcLength; i++) {
                var item = {
                    name: partitionSrc[i],
                    type: 'line',
                    showSymbol: false,
                    data: yCount.splice(0, dateLength)
                }

                lgend_data.push(item);
            }
            ;

            for (var i = 0; i < partitionLength; i++) {
                var item = {
                    name: partitionArr[i],
                    type: 'line',
                    showSymbol: false,
                    data: yCount1.splice(0, dateLength),
                    xAxisIndex: 1,
                    yAxisIndex: 1
                }

                lgend_data.push(item);
            }
            ;
            return lgend_data;
        }

        $scope.select = function () {
            if ($scope.timeType == '1d') {
                $scope.startTime = getToday00Clock().Format("yyyy-MM-ddThh:mm:ss.S");
                $scope.endTime = getToday11Clock().Format("yyyy-MM-ddThh:mm:ss.S");
                $interval.cancel(timer);
                queryLoginTotal();
                queryCallServiceTotal();
                queryFrameTotal();
                queryAsyncRouteSendTotal();
                queryAsyncRouteReceiveTotal();
                queryBatchTotal();
                callServiceLine();
                timer = $interval(function () {
                    queryLoginTotal();
                    queryCallServiceTotal();
                    queryFrameTotal();
                    queryAsyncRouteSendTotal();
                    queryAsyncRouteReceiveTotal();
                    queryBatchTotal();
                    callServiceLine();
                    asyncRouteLine();
                }, 60000);
                if (isMulti == 'true') {
                    mapService();
                    timer = $interval(function () {
                        mapService();
                    }, 60000);
                } else if (isMulti == 'false') {
                    queryCallFrameServiceTop10()
                    timer = $interval(function () {
                        queryCallFrameServiceTop10()
                    }, 60000);
                }
                asyncRouteLine();

            } else if ($scope.timeType == '1h') {
                $scope.currentTime.setHours($scope.currentTime.getHours() - 1);
                $scope.startTime = ($scope.currentTime.Format("yyyy-MM-ddThh:mm:ss.S"));
                $scope.currentTime = new Date();
                $scope.endTime = $scope.currentTime.Format("yyyy-MM-ddThh:mm:ss.S");
                $interval.cancel(timer);
                queryLoginTotal();
                queryCallServiceTotal();
                queryFrameTotal();
                queryAsyncRouteSendTotal();
                queryAsyncRouteReceiveTotal();
                queryBatchTotal();
                callServiceLine();
                if (isMulti == 'true') {
                    mapService();
                    timer = $interval(function () {
                        mapService();
                    }, 60000);
                } else if (isMulti == 'false') {
                    queryCallFrameServiceTop10()
                    timer = $interval(function () {
                        queryCallFrameServiceTop10()
                    }, 60000);
                }

                asyncRouteLine();
                timer = $interval(function () {
                    queryLoginTotal();
                    queryCallServiceTotal();
                    queryFrameTotal();
                    queryAsyncRouteSendTotal();
                    queryAsyncRouteReceiveTotal();
                    queryBatchTotal();
                    callServiceLine();
                    asyncRouteLine();
                }, 60000);
            } else if ($scope.timeType == '4h') {
                $scope.currentTime.setHours($scope.currentTime.getHours() - 4);
                $scope.startTime = $scope.currentTime.Format("yyyy-MM-ddThh:mm:ss.S");
                $scope.currentTime = new Date();
                $scope.endTime = $scope.currentTime.Format("yyyy-MM-ddThh:mm:ss.S");
                $interval.cancel(timer);
                queryLoginTotal();
                queryCallServiceTotal();
                queryFrameTotal();
                queryAsyncRouteSendTotal();
                queryAsyncRouteReceiveTotal();
                queryBatchTotal();
                callServiceLine();
                if (isMulti == 'true') {
                    mapService();
                    timer = $interval(function () {
                        mapService();
                    }, 60000);
                } else if (isMulti == 'false') {
                    queryCallFrameServiceTop10()
                    timer = $interval(function () {
                        queryCallFrameServiceTop10()
                    }, 60000);
                }

                asyncRouteLine();
                timer = $interval(function () {
                    queryLoginTotal();
                    queryCallServiceTotal();
                    queryFrameTotal();
                    queryAsyncRouteSendTotal();
                    queryAsyncRouteReceiveTotal();
                    queryBatchTotal();
                    callServiceLine();
                    asyncRouteLine();
                }, 60000);
            } else if ($scope.timeType == '12h') {
                $scope.currentTime.setHours($scope.currentTime.getHours() - 12);
                $scope.startTime = $scope.currentTime.Format("yyyy-MM-ddThh:mm:ss.S");
                $scope.currentTime = new Date();
                $scope.endTime = $scope.currentTime.Format("yyyy-MM-ddThh:mm:ss.S");
                $interval.cancel(timer);
                queryLoginTotal();
                queryCallServiceTotal();
                queryFrameTotal();
                queryAsyncRouteSendTotal();
                queryAsyncRouteReceiveTotal();
                queryBatchTotal();
                callServiceLine();
                if (isMulti == 'true') {
                    mapService();
                    timer = $interval(function () {
                        mapService();
                    }, 60000);
                } else if (isMulti == 'false') {
                    queryCallFrameServiceTop10()
                    timer = $interval(function () {
                        queryCallFrameServiceTop10()
                    }, 60000);
                }

                asyncRouteLine();
                timer = $interval(function () {
                    queryLoginTotal();
                    queryCallServiceTotal();
                    queryFrameTotal();
                    queryAsyncRouteSendTotal();
                    queryAsyncRouteReceiveTotal();
                    queryBatchTotal();
                    callServiceLine();
                    asyncRouteLine();
                }, 60000);
            } else if ($scope.timeType == '8h') {
                $scope.startTime = getToday08Clock().Format("yyyy-MM-ddThh:mm:ss.S");
                $scope.endTime = getToday17Clock().Format("yyyy-MM-ddThh:mm:ss.S");
                $interval.cancel(timer);
                queryLoginTotal();
                queryCallServiceTotal();
                queryFrameTotal();
                queryAsyncRouteSendTotal();
                queryAsyncRouteReceiveTotal();
                queryBatchTotal();
                callServiceLine();
                if (isMulti == 'true') {
                    mapService();
                    timer = $interval(function () {
                        mapService();
                    }, 60000);
                } else if (isMulti == 'false') {
                    queryCallFrameServiceTop10()
                    timer = $interval(function () {
                        queryCallFrameServiceTop10()
                    }, 60000);
                }

                asyncRouteLine();
                timer = $interval(function () {
                    queryLoginTotal();
                    queryCallServiceTotal();
                    queryFrameTotal();
                    queryAsyncRouteSendTotal();
                    queryAsyncRouteReceiveTotal();
                    queryBatchTotal();
                    callServiceLine();
                    asyncRouteLine();
                }, 60000);
            }
        }
        window.onresize = function () {
            callServiceLineEcharts.resize();
            callFrameServiceEchart.resize();
            mapEchart.resize();
        }

        function getToday08Clock() {
            var date = new Date();
            date.setHours(8);
            date.setMinutes(0);
            date.setSeconds(0);
            date.setMilliseconds(0);
            return date;
        }

        function getToday17Clock() {
            var date = new Date();
            date.setHours(17);
            date.setMinutes(0);
            date.setSeconds(0);
            date.setMilliseconds(0);
            return date;
        }

        window.onresize = function () {
            callServiceLineEcharts.resize();
            asyncRouteLineEcharts.resize();
            callFrameServiceEchart.resize();

        }
    }


})();









